//位于store.js 中
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);

export default new Vuex.Store({
  /*
  * state指的就是储存的数据，
  * 下面的数据是我在项目中需要用的数据字段
  * */
  state: {
    txt: '',
    title: '',
    author: '',
    type: '',
    resource: '',
    date: '',
    cover: '',
    press: ''
  },
  /*
    * mutations里面规定的就是想要改变state(数据)的动作函数，
    * 下面的user_message 就是我将传入的message赋值给仓库中的
    * state数据字段，达到更新数据的目的
    * */
  mutations: {
    user_message (state, message) {
      state.txt = message;
    },
    content (state, message) {
      state.title = message.title;
      state.author = message.author;
      state.type = message.type;
      state.resource = message.resource;
      state.date = message.date;
      state.cover = message.cover
      state.press = message.press
    }
  }
})
